﻿using Microsoft.EntityFrameworkCore;
using Volo.Abp;
using Volo.Abp.EntityFrameworkCore.Modeling;

namespace Himp.Outpatient.EntityFrameworkCore;

public static class OutpatientDbContextModelCreatingExtensions
{
    public static void ConfigureOutpatient(
        this ModelBuilder builder)
    {
        Check.NotNull(builder, nameof(builder));

        /* Configure all entities here. Example:

        builder.Entity<Question>(b =>
        {
            //Configure table & schema name
            b.ToTable(OutpatientDbProperties.DbTablePrefix + "Questions", OutpatientDbProperties.DbSchema);

            b.ConfigureByConvention();

            //Properties
            b.Property(q => q.Title).IsRequired().HasMaxLength(QuestionConsts.MaxTitleLength);

            //Relations
            b.HasMany(question => question.Tags).WithOne().HasForeignKey(qt => qt.QuestionId);

            //Indexes
            b.HasIndex(q => q.CreationTime);
        });
        */

        #region 门诊挂号

        builder.Entity<OtpRgstType>(b =>
        {
            b.ToTable(OutpatientDbProperties.DbTablePrefix + nameof(OtpRgstType), OutpatientDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<OtpOperRm>(b =>
        {
            b.ToTable(OutpatientDbProperties.DbTablePrefix + nameof(OtpOperRm), OutpatientDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<OtpRgstRec>(b =>
        {
            b.ToTable(OutpatientDbProperties.DbTablePrefix + nameof(OtpRgstRec), OutpatientDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<OtpRgstTypeAssocPubItem>(b =>
        {
            b.ToTable(OutpatientDbProperties.DbTablePrefix + nameof(OtpRgstTypeAssocPubItem), OutpatientDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<OtpRgstOrd>(b =>
        {
            b.ToTable(OutpatientDbProperties.DbTablePrefix + nameof(OtpRgstOrd), OutpatientDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        #endregion

        #region 门诊排班

        builder.Entity<OtpSchdType>(b =>
        {
            b.ToTable(OutpatientDbProperties.DbTablePrefix + nameof(OtpSchdType), OutpatientDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<OtpSchdPeriod>(b =>
        {
            b.ToTable(OutpatientDbProperties.DbTablePrefix + nameof(OtpSchdPeriod), OutpatientDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<OtpSchdPlan>(b =>
        {
            b.ToTable(OutpatientDbProperties.DbTablePrefix + nameof(OtpSchdPlan), OutpatientDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<OtpSchdRec>(b =>
        {
            b.ToTable(OutpatientDbProperties.DbTablePrefix + nameof(OtpSchdRec), OutpatientDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<OtpSchdRecDetl>(b =>
        {
            b.ToTable(OutpatientDbProperties.DbTablePrefix + nameof(OtpSchdRecDetl), OutpatientDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        #endregion

        #region 门诊设置

        builder.Entity<OtpSetlType>(b =>
        {
            b.ToTable(OutpatientDbProperties.DbTablePrefix + nameof(OtpSetlType), OutpatientDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        #endregion

        #region 门诊导诊

        builder.Entity<OtpQueueRec>(b =>
        {
            b.ToTable(OutpatientDbProperties.DbTablePrefix + nameof(OtpQueueRec), OutpatientDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<OtpWkstLoginRec>(b =>
        {
            b.ToTable(OutpatientDbProperties.DbTablePrefix + nameof(OtpWkstLoginRec), OutpatientDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        #endregion

        #region 门诊订单

        builder.Entity<OtpOrdRec>(b =>
        {
            b.ToTable(OutpatientDbProperties.DbTablePrefix + nameof(OtpOrdRec), OutpatientDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<OtpOrdDetl>(b =>
        {
            b.ToTable(OutpatientDbProperties.DbTablePrefix + nameof(OtpOrdDetl), OutpatientDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<OtpOrdFeeDetl>(b =>
        {
            b.ToTable(OutpatientDbProperties.DbTablePrefix + nameof(OtpOrdFeeDetl), OutpatientDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<OtpPayRec>(b =>
        {
            b.ToTable(OutpatientDbProperties.DbTablePrefix + nameof(OtpPayRec), OutpatientDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<OtpPayWay>(b =>
        {
            b.ToTable(OutpatientDbProperties.DbTablePrefix + nameof(OtpPayWay), OutpatientDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        #endregion

        #region 门诊就诊

        builder.Entity<OtpMdtrtRec>(b =>
        {
            b.ToTable(OutpatientDbProperties.DbTablePrefix + nameof(OtpMdtrtRec), OutpatientDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<OtpRxType>(b =>
        {
            b.ToTable(OutpatientDbProperties.DbTablePrefix + nameof(OtpRxType), OutpatientDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<OtpRxRec>(b =>
        {
            b.ToTable(OutpatientDbProperties.DbTablePrefix + nameof(OtpRxRec), OutpatientDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<OtpRxRecDetl>(b =>
        {
            b.ToTable(OutpatientDbProperties.DbTablePrefix + nameof(OtpRxRecDetl), OutpatientDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<OtpRxOrd>(b =>
        {
            b.ToTable(OutpatientDbProperties.DbTablePrefix + nameof(OtpRxOrd), OutpatientDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<OtpMdtrtAssocOrd>(b =>
        {
            b.ToTable(OutpatientDbProperties.DbTablePrefix + nameof(OtpMdtrtAssocOrd), OutpatientDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<OtpAppyForm>(b =>
        {
            b.ToTable(OutpatientDbProperties.DbTablePrefix + nameof(OtpAppyForm), OutpatientDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<OtpAppyFormDetl>(b =>
        {
            b.ToTable(OutpatientDbProperties.DbTablePrefix + nameof(OtpAppyFormDetl), OutpatientDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        #endregion

        #region 门诊发票

        builder.Entity<InvoUsedRec>(b =>
        {
            b.ToTable(OutpatientDbProperties.DbTablePrefix + nameof(InvoUsedRec), OutpatientDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<OtpInvo>(b =>
        {
            b.ToTable(OutpatientDbProperties.DbTablePrefix + nameof(OtpInvo), OutpatientDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        #endregion
    }
}
